package http

import (
	"net/http"

	"gitee.com/ldysdy999/httpprobe/config"
	"github.com/gin-gonic/gin"
)

func StartGin(c *config.Config) {
	//初始化gin实例
	r := gin.Default()
	//绑定路由
	Routes(r)

	r.Run(c.HttpListenAddr)
}

/*添加路由
  - /probe/http
  - /v1
  - /api/probe/http?host=baidu.com&is_https=1
*/
func Routes(r *gin.Engine) {
	//api group共享前缀path
	api := r.Group("/api")
	api.GET("/probe/http", HttpProbe)
	api.GET("/v1", func(c *gin.Context) {
		c.String(http.StatusOK, "你好，我是 http prober")
	})
}
